import { defineStore } from "pinia";

import { getStudentList, addStudent, updateStudent, deleteStudent } from "@/api/student";

interface IStudent{
    id: string,
    name: string,
    age: number,
    sex: string,
    phone: string,
    email: string,
    address: string,
    major: string,
    grade: string,
    college: string,
    class: string,
    remark: string
}

export const useStudentStore = defineStore("student", {
    state: () => {
        return {
            studentList: [] as IStudent[],
            currentPage: 1,
            pageSize: 10,
            total: 0,
        }
    },
    actions: {
        async fetchStudentList(){
            const {data} = await getStudentList(this.currentPage, this.pageSize)
           this.studentList = data.list
        }
    }
})